<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>

	<head>
		<meta http-equiv="Content-Type" content="text/html; 

charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>信息终端管理</title>
		<%@ include file="/commons/css_js_head.jsp"%>
<!-- 模式窗口 -->
<script type="text/javascript" src="../lhgdialog/lhgcore.min.js"></script>
<script type="text/javascript" src="../lhgdialog/lhgdialog.min.js"></script>

<script type="text/javascript">
//复写Url
doListUrl = "${ctx }/base/tsMachinesAction!doList.ts";
doAddBeforeUrl = "${ctx }/base/tsMachinesAction!doFindById.ts";
doUpdateBeforeUrl = "${ctx }/base/tsMachinesAction!doFindById.ts";
doDelUrl = "${ctx }/base/tsMachinesAction!doDelete.ts"
doAddApplyBeforeUrl="${ctx }/base/machinesApplyAction!doList.ts"
doChangeBeforeUrl = "${ctx }/base/tsMachinesAction!doChangeById.ts";
//添加之前
function doAddBefore() {
	var _form = document.forms[0];
	if (doAddBeforeUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}

	_form.action = doAddBeforeUrl;
	_form.submit();
}

//增加机器应用之前
function doAddApply(pkId){
	var _form = document.forms[0];
	if (doAddBeforeUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
	_form.action = doAddApplyBeforeUrl + "?machinesId=" + pkId;
	_form.submit();
}



//更新之前 
function doUpdateBefore(pkId) {
	//var _form = document.forms[0];
	//if (doUpdateBeforeUrl == '') {
	//	alert('请设置正确的URL!');
	//	return false;
	//}

	//_form.action = doUpdateBeforeUrl + "?machinesId=" + pkId;
	//_form.submit();
	
	tb_show("add","${ctx }/base/tsMachinesAction!doFindById.ts?machinesId="+ pkId+"&keepThis=true&TB_iframe=true&width=700&height=196&modal=true",false);
}




//删除
function doDel(pkId) {
	var _form = document.forms[0];
	if (doDelUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
		if(confirm("确定要下线吗?"))
		{
			$.ajax({
      type : "post",
      url : "${ctx }/base/tsMachinesAction!checkIsOffLine.ts",
      cache: false,
      data : "&machinesId="+pkId,
      success : function(data){
      
      if( data != "0" )
       {
          alert("下线前，请先取消应用！");
          
           return false;
        }
       else
       {
            _form.action = doDelUrl + "?machinesId=" + pkId;
			_form.submit();
          return true;
       }
      },
     error: function(){
     	  
           return false;
     	}
   });
		
		
			
		}
		return false;
	
}



function doAdd1(pkId){
  
  tb_show("add","${ctx}/base/machinesApplyAction!doList.ts?msid=" + 

pkId+"&keepThis=true&TB_iframe=true&width=600&height=496&modal=true",false);
  //this.blur();
}

//更换之前 
function doChangeBefore(pkId) {
	
	
	tb_show("add","${ctx }/base/tsMachinesAction!doChangeById.ts?machinesId="+ pkId+"&keepThis=true&TB_iframe=true&width=700&height=196&modal=true",false);
}

function toImport1(){
	 tb_show("add","${ctx }/base/tsMachinesAction!toImport.ts?keepThis=true&TB_iframe=true&width=700&height=296&modal=true",false);
}
function toExport1(){
	 tb_show("add","${ctx }/base/tsMachinesAction!toExport.ts?keepThis=true&TB_iframe=true&width=500&height=296&modal=true",false);
}

function queryMon(url) {
	if (url == '') {
		alert('请先正确配置交换中心地址!');
		return false;
	}
	var showDiag = new J.dialog( {
			id:"two_",
			title : "查看交换中心",
			page : url,
			rang : true,
			iconTitle : false,
			autoSize : true,
			height  :500,
			width  :900,
			cover : false,
			resize : true,
			iconTitle : false,
			minBtn : false,
			maxBtn : false,
			xButton : true,
			btnBar : true,
			link : true
		});
		showDiag.ShowDialog();
}

</script>


	</head>
	<body style="overflow-x: hidden">

		<!-- 标题 -->
		<div class="mTitle">
			<span class="hidsearch"><a href="javascript:void(0)"
				onClick="return chg('searchList');" id="ImgArrow"> 
				<img src="${ctx}/images/icon_up.gif" id="imgButton" />
			</a> </span>
			<b class="bbig">信息终端管理</b>
			<a href="javascript:void(0)" onclick="javascript:doAddBefore();" >增加信息终端</a>
			<a href="javascript:void(0)" onclick="javascript:toImport1();" >导入信息终端</a>
			<a href="javascript:void(0)" onclick="javascript:toExport1();" >导出信息终端</a>
		</div>

		<!--list -->
		<div class="searchBar" id="searchList" style="display: block;">
			<form action="${ctx }/base/tsMachinesAction!doList.ts" method="post">
				<table class="searchTable">
					<tr>
						<th>
							厂家编码：
						</th>
						<td>
							<s:textfield name="compCode" theme="simple" ></s:textfield>
						</td>
						
						
						<th>
							设备名称：
						</th>
						<td>
							<s:textfield name="name" theme="simple"></s:textfield>
						</td>
						
						<th>
							 设备类型：
						</th>
						<td>
							      <s:select
                                 theme="simple"
                                 name="theIdMachine"
                                 list="#request.list" 
                                 cssStyle="width:83px;"	
                                 listKey="theIdMachine" 
                                 listValue="name"
                                 headerKey=""
                                 headerValue="请选择类型"						          	
                			     id="select">
							</s:select>
						</td>
						<th>
						是否上线：
						</th>
						<td>
						<s:select list="#{1:'是',0:'否'}" 
							theme="simple"
                            name="status" 
						    cssStyle="width:50px;"
							listKey="key" 
							listValue="value"  
							headerKey="0"
							/> 
						</td>
						
						<td>
							<input name="btn_query" type="button" class="btn" value="查询" onclick="doQuery()" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div class="mainList">

			<table class="listTable">
				<tr>
					<th>序号</th>
					<th>
						设备名称
					</th>
					<th>
						设备类型
					</th>
					
					<th>
						机器码
					</th>
					<th>
						授权码
					</th>
					<th>
						状态
					</th>
					<th>
						地址
					</th>
					<th>批次</th>
					<th>
						操作
					</th>
				</tr>

				<c:forEach var="machine" varStatus="status" items="${pager.data}">
					<tr align=center>
						<td>${status.index+1} </td>
						<td>
							${machine.name}
						</td>
						<td>
							${machine.theIdMachine}
						</td>
						
						<td>
							${machine.deviceCode}
						</td>
						<td>
						${machine.deviceRandom }
						</td>
						<td>
						<c:if test="${machine.type == '0000000000000000'}">  <span>正常</span> </c:if>
						 <c:if test="${machine.type != '0000000000000000'}">  <span> <font color="red">${machine.type}</font> </span> </c:if>
						</td>
						<td>
						${machine.address}
						</td>
						<td>
						${machine.batch}
						</td>
						<td>
								
									
								<c:if test="${machine.status == '1'}">
								<a href="javascript:void(0)" onclick="javascript:doUpdateBefore('${machine.mid}');"><span
									class="icon_edit">&nbsp;</span>修改</a>
									<a href="javascript:void(0)" onclick="javascript:doChangeBefore('${machine.mid}');"><span
									class="icon_edit">&nbsp;</span>更换</a>
									<a href="javascript:void(0)" onclick="javascript:doDel('${machine.mid}');"><span
									class="icon_del">&nbsp;</span>下线</a>
								</c:if>
							<a href="javascript:void(0)" onclick="javascript:doAdd1('${machine.mid}')"><span
								class="icon_add">&nbsp;</span>应用服务查询</a>
							<c:if test="${machine.userName != ''}">
							<a href="javascript:void(0)" onclick="javascript:queryMon('http://${machine.userName}:8080/switch-platform/health/jms-record-external-list.action?code=${machine.deviceCode}');"><span
								class="icon_add">&nbsp;</span>上卡数据查询</a>
								<a href="javascript:void(0)" onclick="javascript:queryMon('http://${machine.userName}:8080/switch-platform/health/hardware-status-list.action?code=${machine.deviceCode}');"><span
								class="icon_add">&nbsp;</span>信息机配置</a>
							</c:if>
							
						</td>
					</tr>
				</c:forEach>
				
			</table>
		</div>
		<!--end list -->

		<!-- 分页区域  -->
<%@ include file="/page/pager.jsp"%>

<script type="text/javascript">
ajaxAnywhere.formName = "form1";
ajaxAnywhere.getZonesToReload = function() {
    return "zoneList";
}
</script>


	</body>
</html>
